var express = require('express');
var router = express.Router();
var i18n = require("../util/i18nLoader");
var constant = require("../constant/constant");
var cookie = require('cookie');
// var parse = require('./lib/parse');

/* GET home page. */
router.get('/', function (req, res, next) {
    // get langName from cookie
    var langName = req.cookies.langName;
    res.render('index',
        {
            title: 'Express',
            name: 'gaowen',
            username: i18n.get(langName, "username"),
            password: i18n.get(langName, "password"),
            username_placeholder: i18n.get(langName, "username_placeholder"),
            password_placeholder: i18n.get(langName, "password_placeholder"),
            login: i18n.get(langName, "login")
        });
});

router.get('/register', function (req, res, next) {
    // get langName from cookie
    var langName = req.cookies.langName;
    res.render('register',
        {
            title: 'Express',
            username: i18n.get(langName, "username"),
            password: i18n.get(langName, "password"),
            username_placeholder: i18n.get(langName, "username_placeholder"),
            password_placeholder: i18n.get(langName, "password_placeholder"),
            register: i18n.get(langName, "register"),
            login: i18n.get(langName, "login")
        });
});

module.exports = router;
